<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<h1 id="title" class="mui-title">我的</h1>
			<a class="mui-icon mui-icon-contact mui-pull-right" ></a>
		</header>
		<div class="mui-content">
			<div id="scroll" class="mui-scroll-wrapper" style="margin-top: 50px;">
				<div class="mui-scroll">
					<!--<div class="mui-card">
						<div class="mui-card-header">
							页眉
						</div>
						<div class="mui-card-content">
							<ul class="mui-table-view mui-table-view-chevron">
								<li class="mui-table-view-cell mui-media">
									<a class="mui-navigate-right">
										<img class="mui-media-object mui-pull-left" src="#">
										<div class="mui-media-body">
											<span>CBD</span>
											<p class='mui-ellipsis'>烤炉模式的城，到黄昏，如同打翻的调色盘一般.</p>
										</div>
									</a>
								</li>
							</ul>
						</div>
					</div>-->
					<div class="mui-card">
						<div class="mui-card-content">
							<ul class="mui-table-view mui-table-view-chevron">
								<li class="mui-table-view-cell mui-media" v-for="book in books">
									<a class="mui-navigate-right" v-on:click="openWindow(book)">
										<img class="mui-media-object mui-pull-left" v-bind:src="book.cover">
										<div class="mui-media-body">
											<span v-html="book.title">CBD</span>
											<p class='mui-ellipsis' v-html="book.shortIntro">烤炉模式的城，到黄昏，如同打翻的调色盘一般.</p>
										</div>
									</a>
								</li>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/vue.min.js"></script>
		<script src="../js/app.js"></script>
		<script type="text/javascript">
			mui.init({ 
			 pullRefresh : {
			　　 swipeBack: false, //关闭左滑关闭功能
			    container:"#scroll",//下拉刷新容器标识，querySelector能定位的css选择器均可，比如：id、.class等
			    down : {
			      style:'circle',//必选，下拉刷新样式，目前支持原生5+ ‘circle’ 样式
			      color:'#2BD009', //可选，默认“#2BD009” 下拉刷新控件颜色
			      height:'50px',//可选,默认50px.下拉刷新控件的高度,
			      range:'100px', //可选 默认100px,控件可下拉拖拽的范围
			      offset:'0px', //可选 默认0px,下拉刷新控件的起始位置
			      auto: true,//可选,默认false.首次加载自动上拉刷新一次
			      callback :pulldownRefresh //必选，刷新函数，根据具体业务来编写，比如通过ajax从服务器获取新数据；
			   },
			});
			var vm = new Vue({
				el: '.mui-content',
				data: {
					gender:"",
					major:"",
					mins:[],
					type:"hot",
					minor:"",
					classify:[],
					start:0,
					limit:20,
					total:0,
					books:[],
				}
			});
			mui.ready(function(){
				mui('#scroll').scroll({
					indicators: true //是否显示滚动条
				});
				vm.classify = app.getClassify();
				pulldownRefresh();
				//loadData('hot');
			});
			
			function pulldownRefresh(){
				setTimeout(function(){
					vm.books = app.getBooks();
					console.log(JSON.stringify(vm.books));
				},500);
			}
			
			function loadData(type){
				console.log("type="+type);
				vm.type = type;
				plus.nativeUI.showWaiting("正在加载数据，请稍等...");
				/*https://api.zhuishushenqi.com/book/by-categories?gender=male&type=hot&major=%E5%A5%87%E5%B9%BB&minor=&start=0&limit=20*/
				var ajaxUrl = "https://api.zhuishushenqi.com/book/by-categories?gender="+vm.gender+"&type="+type+"&major="+vm.major+"&minor=&start="+vm.start+"&limit="+vm.limit;
				console.log(ajaxUrl);
				mui.getJSON(ajaxUrl, {}, function(rsp) {
					plus.nativeUI.closeWaiting();
					console.log(JSON.stringify(rsp));
					if(rsp.ok && rsp.ok == false){
						plus.nativeUI.alert(rsp.msg);
						return;
					}
					if(rsp.ok && rsp.ok == true){
						//vm.keyValue = rsp._id;
						vm.total = rsp.total;
						var books = rsp.books;
						books.forEach(function(item){
							//console.log(item.cover);
							item.cover ="http://statics.zhuishushenqi.com"+ item.cover;
						});
						vm.books = books;
					}
				});
			}
			
			function openWindow(item){
				console.log(JSON.stringify(item));
				mui.openWindow({id: 'bookinfo.html',url: 'bookinfo.html'
					,show: {aniShow: 'pop-in'}
					,extras: {    //extras里面的就是参数了
	                	keyValue: item._id,
	                	title:item.title,
	                	monthRank:item.monthRank,
	                	totalRank:item.totalRank,
	           		}
					,waiting: {
						autoShow: true, //自动显示等待框，默认为true
	           		}
  				});
			}
		</script>
	</body>

</html>